<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<%@ include file="../include/vueComponent.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>投标决策详情</title>
</head>
<style>
    .unit_img div {
        height: 41px;
    }
</style>
<link rel="stylesheet" href="${ctx}/resources/vue-element-lib/detail.css">
<body>
<div id="app">
    <div class="layui-tab layui-tab-brief" lay-filter="xqxx-tab-all">
        <ul class="layui-tab-title">
            <li id="tbglId" class="layui-this" lay-id="0">投标决策详情</li>
            <li id="zgysId" lay-id="1">历史审批信息</li>
        </ul>
        <div class="layui-tab-right">
            <c:if test="${isAuditFlag eq '1'}">
                <template v-if="layId==0">
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" @click="save(0)">保存
                    </button>
                    <button type="button" class="layui-btn layui-btn-radius" @click="save(1)">提交</button>
                </template>
            </c:if>
            <c:if test="${auditTabFlag eq '1'}">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" @click="audit(0)">
                    不同意
                </button>
                <button type="button" class="layui-btn layui-btn-radius" @click="audit(1)">同意</button>
            </c:if>
        </div>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show">
                <div class="container">
                    <el-form ref="formRef" label-width="180px" label-suffix="："
                             label-position="left">
                        <%--项目基础信息--%>

                        <div class="title">
                            <h3>项目基础信息</h3>
                        </div>
                        <!--表单-->
                        <el-row>
                            <x-col>
                                <el-form-item label="项目名称">
                                    <span>{{info.proName}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="所属公司">
                                    <span>{{info.compName}}</span>
                                </el-form-item>
                            </x-col>


                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="项目编码">
                                    <span>{{info.proCode}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="营销经理">
                                    <span>{{info.staffName}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="实施机构">
                                    <span>{{info.carryOrg}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="回报机制">
                                    <span>{{info.backMech}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="投资总额(万元)">
                                    <span>{{info.sumAmount}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="建安工程费(万元)">
                                    <span>{{info.costCae}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="建设周期(年)">
                                    <span>{{info.buildYears}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="运营周期(年)">
                                    <span>{{info.omYears}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="投标保证金截止日期">
                                    <span>{{info.bondEndDate}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="投标保证金(万元)">
                                    <span>{{info.bondMoney}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="项目简介">
                                    <span>{{info.proRemarks}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>

                        <%--项目投资构成--%>
                        <div class="title">
                            <h3>项目投资构成</h3>
                        </div>
                        <el-row>
                            <x-col>
                                <el-form-item label="建安工程费(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.costCae" name="建安工程费"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="设备购置工程费(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.deviceCost" name="设备购置工程费"/>
                                </el-form-item>
                            </x-col>

                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="工程建设其他费(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.otherCost" name="工程建设其他费"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="征地拆迁费(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.moveOutCost" name="征地拆迁费"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="预备费(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.inReadyCost" name="预备费"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="建设期利息(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.periodInterest" name="建设期利息"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <%--经济分析--%>
                        <div class="title" style="margin-top: 30px">
                            <h3>经济分析</h3>
                        </div>
                        <el-row>
                            <x-col>
                                <el-form-item label="资本金要求" :rules="[{ required: true}]">
                                    <x-input v-model="info.capitalFund" name="资本金要求"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="股权比例(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.stockPercent" name="股权比例"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="建安下浮率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.jianAnDownRate" name="建安下浮率" value="info.jianAnDownRate"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="合理利润率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.profitRate" name="合理利润率"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="综合回报率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.compreRate" name="综合回报率"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="年度折现率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.yearDiscountRate" name="年度折现率"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="建筑施工利润率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.buildConstrRate" name="建筑施工利润率"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="投资利润率(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.investProfitRate" name="投资利润率"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="运营利润(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.operatProfit" name="运营利润"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="综合利润(%)" :rules="[{ required: true}]">
                                    <x-input v-model="info.comperProfit" name="综合利润"
                                             oninput="if(isNaN(value)) { value = null } if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <div class="title">
                            <h3>项目其他信息</h3>
                        </div>
                        <el-row>
                            <x-col>
                                <el-form-item label="意向申请会议日期" :rules="[{ required: true}]">
                                    <el-date-picker v-model="info.intentionMeetTime" style="width: 100%" type="date"
                                                    value-format="yyyy-MM-dd" placeholder="意向申请会议日期"></el-date-picker>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="财政支付的政府" :rules="[{ required: true}]">
                                    <x-input v-model="info.financePayGov" name="财政支付的政府"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="上一年财政预算收入(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.upYearRevenue" name="上一年财政预算收入"/>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="入库所处阶段" :rules="[{ required: true}]">
                                    <x-input v-model="info.storeStage" name="入库所处阶段"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="是否有居间人" :rules="[{ required: true}]">
                                    <x-select v-model="info.isBroker" :options="yesOrNo" name="是否有居间人"></x-select>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="预计居间人费用(万元)" :rules="[{ required: true}]">
                                    <x-input v-model="info.brokerMoney" name="预计居间人费用" type="number" min="0"/>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="是否入财政部项目库" :rules="[{ required: true}]">
                                    <x-select v-model="info.isProjectLib" :options="yesOrNo"
                                              name="是否入财政部项目库"></x-select>
                                </el-form-item>
                            </x-col>
                            <x-col position="right" v-if="isThoughFlag==1">
                                <el-form-item label="是否决策投标" :rules="[{ required: true}]">
                                    <x-select v-model="info.isDecBid" :options="yesOrNo" name="是否决策投标"></x-select>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="初步融资方案" :rules="[{ required: true}]">
                                    <x-input v-model="info.financingOptions" name="项目简介" type="textarea"
                                             :rows="4"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <div class="unit">
                            <div class="unit_add">
                                <button class="layui-btn layuiadmin-btn-admin" type="button" data-type="add"
                                        @click="addRiskTable">
                                    <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加项目风险
                                </button>
                            </div>
                            <div class="unit_center">
                                <div class="unit_img">
                                    <div class="item" v-for="(item,index) in riskTable" :key="index"
                                         v-if="riskTable.length>1">
                                        <img src="${ctx}/resources/images/del.png" alt="" @click="delRiskTable(index)"
                                             v-if="item.add">
                                    </div>
                                </div>

                                <el-table :data="riskTable" style="width: 100%" border>
                                    <el-table-column prop="riskDesc" label="风险描述" align="center">
                                        <template slot-scope="scope">
                                            <x-input v-model="scope.row.riskDesc" name="风险描述"
                                                     :disabled="!scope.row.add"/>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="riskLevel" label="风险等级" align="center">
                                        <template slot-scope="scope">
                                            <x-select v-model="scope.row.riskLevel" :options="riskLevel"
                                                      :disabled="!scope.row.add"
                                                      name="风险等级"></x-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="solveWay" label="处理策略" align="center">
                                        <template slot-scope="scope">
                                            <x-select v-model="scope.row.solveWay" :options="riskSolveWay"
                                                      :disabled="!scope.row.add"
                                                      name="处理策略"></x-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="latestProgress" label="最新进展"
                                                     align="center">
                                        <template slot-scope="scope">
                                            <x-input v-model="scope.row.latestProgress" name="最新进展"
                                                     :disabled="!scope.row.add"/>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </div>
                        <el-row>
                            <x-col position="full">
                                <el-form-item label="其他说明" :rules="[{ required: true}]">
                                    <x-input v-model="info.otherInstructions" name="其他说明" type="textarea"
                                             :rows="4"></x-input>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <div class="title">
                            <h3>项目附件信息</h3>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标前承诺</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="41-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="41-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">居间合同</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="42-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="42-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">融资调研报告</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="18-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="18-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">运营调研报告</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="16-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="16-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">招商调研报告</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="17-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="17-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">当地PPP项目调研报告 </label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="19-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="19-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">招标文件</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="20-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="20-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">PPP合同范本</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="21-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="21-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">投资测算表</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" type="button" id="22-upload-more">上传
                                    </button>
                                    <div class="layui-upload-list" id="22-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <c:if test="${auditTabFlag eq '1'}">
                            <div class="title">
                                <h3>审批信息</h3>
                            </div>
                            <%@ include file="process/process-audit.jsp" %>
                        </c:if>
                    </el-form>
                </div>
            </div>
            <div class="layui-tab-item">
                <%@ include file="process/process-history.jsp" %>
            </div>
        </div>
    </div>
</div>
<script src="${ctx}/resources/vue-element-lib/jquery.js"></script>
<script>
    // 封装上传文件
    let fileArr = [];

    var staticPath = '${fileHttpPre}';
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'upload', 'table', 'transfer', 'laydate', 'element', 'layer'], function () {
        var $ = layui.$
            , upload = layui.upload
            , table = layui.table
            , element = layui.element
            , layer = layui.layer;

        //选项卡切换监听
        element.on('tab(xqxx-tab-all)', function (data) {
            var layId = $(this).attr('lay-id');
            vm.$data.layId = layId
            if (layId === "0") {

            } else if (layId === "1") {
                loadTable(layId);
            } else if (layId === "2") {

            }
        });

        function loadTable(layId) {
            // 表单
            table.render({
                elem: '#lay-lsspxx-create-manage'
                , url: basePath + '/historyProcess/list?proCode=${proCode}'
                , cols: [[
                    {
                        field: 'startTime', title: '发起时间', width: 145, width: 155, templet: function (d) {
                            return layui.util.toDateString(d.startTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    , {field: 'startRealName', title: '发起人', width: 145}
                    , {field: 'proFlowType', title: '审批阶段', width: 145}
                    , {field: 'proFlowNode', title: '审批节点', width: 145}
                    , {
                        field: 'dealTime', title: '审批日期', width: 155, templet: function (d) {
                            return layui.util.toDateString(d.dealTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    , {field: 'dealName', title: '审批人', width: 160}
                    , {
                        field: 'state', title: '审批状态'
                    }
                    , {
                        title: '操作', width: 140, align: 'center', fixed: 'right', templet: function (d) {
                            var optStr = "";
                            optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>查看</a>';
                            return optStr;
                        }
                    }
                ]]
                , page: true
                , limit: 10
            });

            // 监听操作列
            table.on('tool(lay-lsspxx-create-manage)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {//查看
                    parent.layui.index.openTabsPage(basePath + '/historyProcess/toDetail?processId=' + data.processId, '历史流程信息 > 详情');
                }
            });
        }

        ;(function () {
            //定义构造函数
            var Upfile = function (ele, type, opt) {
                this.defaults = {
                    //elem:‘#uploadPic‘	//绑定元素
                    elem: $(ele)	//绑定元素
                    , url: basePath + '/contractInfo/uploadAtt/',
                    data: {
                        types: type
                    },
                    multiple: true,
                    accept: 'file',
                    acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',

                    method: 'post',
                    before: function (obj) { //obj参数包含的信息
                        layer.load(); //上传loading
                    },
                    done: function (res) {
                        //如果上传失败
                        if (res.code > 0) {
                            layer.closeAll('loading'); //关闭loading
                            return layer.msg(res.msg, {icon: 7});
                        }
                        //上传完毕
                        if (res.entity != null && res.entity.length > 0) {
                            fileArr.push(res.entity[0])
                            for (var i in res.entity) {
                                var contractInfo = res.entity[i];
                                var arr = contractInfo.split("|");
                                var imgSrc = "";
                                var suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                                if (suffix == 'jpg' || suffix == 'png') {
                                    imgSrc = "${fileHttpPre}/" + arr[3];
                                } else {
                                    imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                                }
                                $('#' + type + '-upload-more-list')
                                    .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                        + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                        + arr[3] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                        + arr[2] + '\')";>删除</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                        + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                            }
                        }
                    },
                    allDone: function (obj) { //当文件全部被提交后，才触发
                        layer.closeAll('loading'); //关闭loading
                    },
                    error: function () {
                        layer.closeAll('loading'); //关闭loading
                        //上传失败
                        layer.msg("上传失败，请稍后再试~", {icon: 7});
                    }
                }
                this.options = $.extend({}, this.defaults, opt);
            };

            //定义方法
            Upfile.prototype = {
                init: function () {
                    var _this = this;
                    return layui.use('upload', function () {
                        var upload = layui.upload;

                        //执行实例
                        var uploadInst = upload.render(_this.options);
                    });
                }
            };

            //在插件中使用对象
            $.fn.upfile = function (options) {
                var upfile = new Upfile(this, options);
                return upfile.init();
            }
        })();
        //上传文件
        $('#41-upload-more').upfile(41);
        $('#42-upload-more').upfile(42);
        $('#16-upload-more').upfile(16);
        $('#17-upload-more').upfile(17);
        $('#18-upload-more').upfile(18);
        $('#19-upload-more').upfile(19);
        $('#20-upload-more').upfile(20);
        $('#21-upload-more').upfile(21);
        $('#22-upload-more').upfile(22);
    });

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
        fileArr.map((el, idx) => {
            if (el.split('|')[2] == index) {
                fileArr.splice(idx, 1)
            }
        })
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url, '', 'left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

    /*核心*/
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                layId: '0',
                procNodeList: [],
                tempNodeList: [],
                auditMsg: '',//审批意见
                riskLevel: [],
                riskSolveWay: [],
                riskTable: [],
                date: '2021-01-01',
                info: {},//信息
                yesOrNo: [],
                id: '',
                isThoughFlag: '',
            }
        },
        created() {
            let that = this;
            that.id = "${id}";
            that.isThoughFlag = "${isThoughFlag}";
            console.log(that.isThoughFlag)
            that.processId = "${processId}";
            that.queryDetailById();
            that.queryProcessList();
        },
        mounted() {

        },
        methods: {
            addRiskTable() {
                let obj = {
                    riskDesc: '',//风险描述
                    riskLevel: '',//风险等级
                    solveWay: '',//处理策略
                    latestProgress: '',//最新进展
                    add: true,
                }
                this.riskTable.push(obj);
            },
            delRiskTable(index) {
                this.riskTable.splice(index, 1);
            },
            showFile(fileList) {
                if (fileList.length > 0) {
                    fileArr = fileList;
                    for (let i in fileList) {
                        let contractInfo = fileList[i];
                        let arr = contractInfo.split("|");
                        let imgSrc = "";
                        let suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                        if (suffix == 'jpg' || suffix == 'png') {
                            imgSrc = "${fileHttpPre}/" + arr[3];
                        } else {
                            imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                        }
                        $('#' + arr[0] + '-upload-more-list')
                            .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                + arr[3] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                + arr[2] + '\')";>删除</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                    }
                }
            },
            queryDetailById() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/bidDecision/queryDetailById',  //请求数据接口
                    data: {id: that.id},
                    success: function (result) {
                        console.log(result)
                        that.info = result.entity.info;
                        that.info = numToStr(that.info);
                        that.yesOrNo = result.entity.yesOrNo;
                        that.riskTable = result.entity.riskTable;
                        that.riskLevel = result.entity.riskLevel;
                        that.riskSolveWay = result.entity.riskSolveWay;
                        if (result.entity.fileAtt && result.entity.fileAtt.length > 0) {
                            if (fileArr.length == 0) {
                                that.showFile(result.entity.fileAtt)
                            }
                        }
                    }
                });
            },
            getArrDifference(arr1, arr2) {
                return arr1.concat(arr2).filter(function (v, i, arr) {
                    return arr.indexOf(v) === arr.lastIndexOf(v);
                });
            },
            error(text) {
                this.$message({
                    message: text,
                    type: 'warning'
                });
            },
            //保存
            save(type) {
                let that = this;
                if (!that.info.costCae) return that.error('请输入建安工程费');
                if (!that.info.deviceCost) return that.error('请输入设备购置工程费');
                if (!that.info.otherCost) return that.error('请输入工程建设其他费');
                if (!that.info.moveOutCost) return that.error('请输入征地拆迁费');
                if (!that.info.inReadyCost) return that.error('请输入预备费');
                if (!that.info.periodInterest) return that.error('请输入建设期利息');
                if (!that.info.capitalFund) return that.error('请输入资本金要求');
                if (!that.info.stockPercent) return that.error('请输入股权比例');
                if (!that.info.jianAnDownRate) return that.error('请输入建安下浮率');
                if (!that.info.profitRate) return that.error('请输入合理利润率');
                if (!that.info.compreRate) return that.error('请输入综合回报率');
                if (!that.info.yearDiscountRate) return that.error('请输入年度折现率');
                if (!that.info.buildConstrRate) return that.error('请输入建筑施工利润率');
                if (!that.info.investProfitRate) return that.error('请输入投资利润率');
                if (!that.info.operatProfit) return that.error('请输入运营利润');
                if (!that.info.comperProfit) return that.error('请输入综合利润');
                if (!that.info.intentionMeetTime) return that.error('请选择意向申请会议日期');
                if (!that.info.financePayGov) return that.error('请输入财政支付的政府');
                if (!that.info.upYearRevenue) return that.error('请输入上一年财政预算收入');
                if (!that.info.storeStage) return that.error('请输入入库所处阶段');
                if (that.info.isBroker == null) return that.error('请选择是否有居间人');
                if (!that.info.brokerMoney) return that.error('请输入预计居间人费用');
                if (that.info.isProjectLib == null) return that.error('请选择是否入财政部项目库');
                if (that.isThoughFlag == '1') {
                    if (!that.info.isDecBid) return that.error('请选择是否决策投标');
                }
                if (!that.info.financingOptions) return that.error('请输入初步融资方案');
                if (!that.info.otherInstructions) return that.error('请输入其他说明');
                let arr = [];
                if (that.riskTable.length > 0) {
                    that.riskTable.map(el => {
                        if (el.add) {
                            arr.push(el);
                        }
                    })
                }
                let obj = {
                    "info": this.info,//项目基础信息
                    "riskTable": arr,
                    "fileAtt": fileArr,//附件信息
                }

                let str = JSON.stringify(obj).replace(/\"/g, '\\"')
                $.ajax({
                    type: 'post',
                    url: basePath + '/bidDecision/edit',  //请求数据接口
                    async: false,
                    data: {
                        bodyStr: str,
                        submitType: type,
                    },
                    success: function (result) {
                        if (result.success) {
                            that.$message({
                                message: '修改成功',
                                type: 'success'
                            });
                            setTimeout(function () {
                                // 刷新首页
                                let index = window.parent.layui.admin.tabsPage.index
                                if (index == null) {
                                    window.close();
                                } else {
                                    var iframe = window.parent.layui.admin.tabsBody((index - 1)).find(".layadmin-iframe");
                                    iframe[0].contentWindow.location.reload();
                                    top.layui.admin.closeThisTabs(); // 关闭当前标签页
                                }
                            }, 3000);
                        } else {
                            that.$message.error(result.msg);
                        }
                    }
                });
            },

            queryProcessList() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/historyProcess/processList',  //请求数据接口
                    data: {processId: that.processId},
                    success: function (result) {
                        if (result.success) {
                            that.procNodeList = result.entity.procNodeList;
                            that.tempNodeList = result.entity.tempNodeList;
                        }
                    }
                });
            },
            audit(status) {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/bidDecision/auditProcess',  //请求数据接口
                    async: false,
                    data: {
                        id: that.id,
                        processId: that.processId,
                        status: status,
                        auditMsg: that.auditMsg
                    },
                    success: function (result) {
                        if (result.success) {
                            that.$message({
                                message: '操作成功',
                                type: 'success'
                            });
                            setTimeout(function () {
                                // 刷新首页
                                let index = window.parent.layui.admin.tabsPage.index
                                if (index == null) {
                                    window.close();
                                } else {
                                    var iframe = window.parent.layui.admin.tabsBody((index - 1)).find(".layadmin-iframe");
                                    iframe[0].contentWindow.location.reload();
                                    top.layui.admin.closeThisTabs(); // 关闭当前标签页
                                }
                            }, 3000);
                        } else {
                            that.$message.error('保存失败');
                        }
                    }
                });
            }
        }
    })
</script>
</body>
</html>

